home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 10
/
AACD 10.iso
/
AACD
/
Magazine
/
Online
/
httpproxy
/
src
/
cache.h
< prev
next >
Wrap
C/C++ Source or Header
|
1996-08-20
|
5KB
|
127 lines
/*(( "Header" */
/*
* $Id: cache.h,v 1.3 1996/08/12 03:33:36 mshopf Exp mshopf $
*
* (c) 1995-96 Matthias Hopf
*
* Cache file maintainance for HttpProxy.
*
*/
/*
* $Log: cache.h,v $
* Revision 1.3 1996/08/12 03:33:36 mshopf
* return (7) for CacheRemove explained.
*
* Revision 1.2 1996/07/30 13:57:03 mshopf
* clean up.
*
* Revision 1.1 1996/07/17 16:42:42 mshopf
* Initial revision
*
*/
/*)) */
#ifndef _CACHE_H__
#define _CACHE_H__
/*(( "Includes" */
#include <exec/types.h>
#include <dos.h>
/*)) */
/*(( "Constants" */
#define CACHEDIRVALIDFILE "@dirurl" /* Checkfile for valid directories */
#define MAX_FILE_DEPTH 8 /* Maximum hirarchy depth */
/* all lengths include trailing '0' byte */
#define MAX_FILE_LEN 32 /* Maximum filename length */
#define MAX_PATH_LEN 128 /* Maximum total path length (dir+file) */
#define MAX_TEMP_LEN 20 /* Maximum size of temporary files (including dir), e.g. @request/013cab02 */
/*)) */
/*(( "Types" */
/* !!! still hacky... to be revised! */
struct _request; /* can't predefine request_t... */
typedef struct {
struct _request *Req;
BPTR File; /* != null when no file is open */
char FileName [MAX_PATH_LEN]; /* the final filename (PUBLIC) */
char TempName [MAX_TEMP_LEN]; /* is "" when no temporary file was needed */
struct DateStamp Date; /* file timestamp */
} cachefile_t;
/*)) */
/*(( "Prototypes" */
/* Initialisation routine. Clean up temporary cache directories. */
/* return 0 on major failure */
int CacheInit (void);
/* Clean up. Called after last cache transaction. No open cache files should exists any more when calling this function. */
/* May be called multiple times. */
void CacheExit (void);
/* Get cache information about a Url. cachefile_t *Cache will be filled for CacheOpen*.
* Missing directories are created, ambiguity is checked, temporary filenames are chosen.
* Returns 0 on no cache existing, 1 on valid cache, -1 on failure (can't create directory /
* double hash error...). Errors are logged.
* 'Date' is valid when a cache file already exists (return value 1). */
// TODO: function for cache expire tests
/* The Cache *must* always be invalidated by CacheClose before reusing! Even when this call
* returned -1! */
int CacheGet (cachefile_t *Cache, const char *Url, struct _request *Req);
/* Open an existing cache file. TempName is cleared. */
/* Returns -1 on failure. Errors are logged. */
int CacheOpenOld (cachefile_t *Cache);
/* Open a new cache file. Url is needed for hash url files... */
/* Returns -1 on failure. Errors are logged. */
int CacheOpenNew (cachefile_t *Cache, const char *Url);
/* Close file, invalidate cache struct, rename file when needed.
* Removes cache file on failure (ok = false = 0). Errors are logged. */
void CacheClose (cachefile_t *Cache, int Ok);
/* Read something from cache file (see Read()) */
int CacheRead (cachefile_t *Cache, void *Buffer, int Len);
/* Write something into cache file (see Write()) */
int CacheWrite (cachefile_t *Cache, const void *Buffer, int Len);
/* The following support functions may be called from any directory level and without
* module initialisation. No external modules are called here. */
/* Get Url name from cache file into Url buffer. Return 0 on failure and on special files. */
int CacheResolve (const char *File, char *Url);
/* Delete cache file / Check cache file state. */
/* returns 1 on success, 2 on invocation on non-deletable special files for directory managment
* (will be deleted by CacheRemoveDir()), 3 on invocation on strange files, 4 on non-existent
* files, 5 on related files (related to other cache files), 6 on special non-deletable files,
* 7 on strange files that should *really* be deleted (hash files without url files and vice versa)
* and 0 on delete errors. Check only the file status on DoDelete == FALSE, perhaps not touching
* the file at all (4 might not be returned). */
/* will return the same values on DoDelete=false as on DoDelete=true */
int CacheRemove (const char *File, int DoDelete);
/* Delete cache dir (special files inside dirs, too). Check only whether the directory should be
* scanned on DoDelete == FALSE. */
/* returns 1 on success, 2 on special directorys, 0 on delete failure. */
/* will not always return the same values on DoDelete=false as on DoDelete=true!!! */
int CacheRemoveDir (const char *Dir, int DoDelete);
/*)) */
#endif /* _CACHE_H__ */